<template>
	<view>
		<view class="content f-26">
			<view class="f-26 f-s">基础信息</view>
			<view class="batch_no">款号：{{list.article_no}}</view>
			<view class="batch_no">颜色：{{list.color}}</view>
			<view class="batch_no">类别：
				<text v-if="list.styletype">{{list.styletype.name}}</text>
			</view>
		</view>
		<view class="paramConter f-26 ">
			<u-field v-model="param.style_score" max="10" label="款式" placeholder="设计感/新颖度/雷同度"></u-field>
			<u-field v-model="param.pattern_score" label="版型" placeholder="显瘦显高"></u-field>
			<u-field v-model="param.color_score" label="颜色" placeholder="挑人/显白/显气质"></u-field>
			<u-field v-model="param.worthiness_score" label="价值感" placeholder="显气质/品位"></u-field>
			<u-field v-model="remarks" label="备注" placeholder="备注"></u-field>
		</view>
		<view class="paramConter f-26 swiper">
			<u-swiper :list="list.image" name="file_path"  @change="changeSwiper"
				:height="imgHeight[index]"></u-swiper>
		</view>
		<view class="save f-s" @click="save">
			评分完成
		</view>
		<u-modal v-model="show" :content="content" @confirm="confirm"></u-modal>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {},
				param: {
					style_score: '',
					pattern_score: '',
					color_score: '',
					worthiness_score: ''
				},
				show: false,
				content: '',
				index: 0,
				imgHeight: [],
				remarks:''
			}
		},
		onLoad(options) {
			this.$u.api.getStyle({
				"style_id": options.id ? options.id : ''
			}).then(res => {
				this.list = res.data;
				const _this = this;
				res.data.image.forEach(ele => {
					uni.getImageInfo({
						src: ele.file_path,
						success: function(image) {
							_this.imgHeight.push(image.height)
							console.log(_this.imgHeight)
						}
					});
				})
			})
		},
		methods: {
			save() {
				for (var i in this.param) {
					if (!this.param[i]) {

						this.$refs.uToast.show({
							title: '输入的值在0-10之间',
							type: 'error',
						})
						return false
					}
					if (!this.$u.test.range(this.param[i], [0, 10])) {
						this.$refs.uToast.show({
							title: '输入的值在0-10之间',
							type: 'error',
						})
						return false
					}
				}
				var newParam = {};
				newParam = JSON.parse(JSON.stringify(this.param));
				newParam.batch_no = this.list.setting.batch_no;
				newParam.article_no = this.list.article_no;
				newParam.style_id = this.list.style_id;
				newParam.remarks = this.remarks;
				this.$u.api.addScore(newParam).then(res => {
					this.content = "操作成功";
					this.show = true;
					// uni.navigateBack({})
				})
			},
			confirm() {
				this.show = false;
				uni.navigateBack({})
			},
			changeSwiper(index) {
				this.index = index;
			}
		}
	}
</script>

<style scoped>
	.content {
		margin: 30rpx 24rpx;
		background: white;
		padding: 30rpx 24rpx;
		border-radius: 8rpx;
	}

	.paramConter {
		margin: 30rpx 24rpx;
		background: white;
		border-radius: 8rpx;
	}

	.batch_no {
		margin-top: 20rpx;
	}

	.style {
		color: rgb(90 136 251);
	}
	.swiper{
		padding-bottom: 100rpx;
	}

	.save {
		position: fixed;
		bottom: 0;
		width: 100%;
		background: #0091FF;
		color: white;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
	}
</style>
